/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Database;
import com.maxmind.geoip.*;
import java.io.IOException;
/**Lets the user get the geographical information involved in a particular IP Address
 * @author Kevin Boerboom
 */
public class IPAddressInfo {

    /**Country name of a particular IP Address
     */
    private String countryName;

    /**City name of a particular IP Address
     */
    private String cityName;


    /**Sets the information involved in the given IP Address
     * @param IPAddress
     */
    public IPAddressInfo(String IPAddress){
        try{
            LookupService c1 = new LookupService("./GeoLiteCity.dat",LookupService.GEOIP_MEMORY_CACHE);
            Location loc = c1.getLocation(IPAddress);
            this.countryName = loc.countryName;
            this.cityName = loc.city;
        }catch(IOException e){
            System.out.println("IO Exception");
        }
    }

    /**
     * Gets the city of the IPAddressInfo object
     * @return the name of the city
     */
    public String getCity(){
        return this.cityName;
    }

    /** Gets the country of the IPAddressInfo object
     * @return the name of the country
     */
    public String getCountry(){
        return this.countryName;
    }
}
